package com.feihong.yw189.activity.dingdan;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.feihong.yw189.R;
import com.feihong.yw189.activity.base.BaseActivity;
import com.feihong.yw189.adapter.PreviewPageAdapter;
import com.feihong.yw189.message.LoginMessage;
import com.feihong.yw189.model.DingDan.YuLanPicModel;
import java.util.List;
import butterknife.ButterKnife;

/**
 */

public class ImageBroawseActivity  extends BaseActivity{

   ViewPager viewPager;
   private List<YuLanPicModel> mImgUrls;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yulan);
        ButterKnife.bind(this);

        viewPager = findViewById(R.id.previewImgViewPager);
        String imgInfo = getIntent().getStringExtra("img");
        if(TextUtils.isEmpty(imgInfo)){
            finish();
            return;
        }
        Log.i(TAG, "onCreate: " + imgInfo);
        mImgUrls = JSON.parseArray(imgInfo,YuLanPicModel.class);

    }

    @Override
    public void setTheme() {
        isDrakFont = false;
    }

    @Override
    public void onUserLogin(LoginMessage loginMessage) {

    }

    @Override
    protected void onResume() {
        super.onResume();
            if(mImgUrls != null && mImgUrls.size() > 0){
                viewPager.setAdapter(new PreviewPageAdapter(mImgUrls,this,() -> {
                    mImgUrls = null;
                    ImageBroawseActivity.this.finish();
                }));
            }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    public interface ImgClickListener{
        void onClickListener();
    }
}
